import create from "../../westore/utils/create"
import store from "../../westore/store"
import Api from "../../utils/api"

const app = getApp(),
regeneratorRuntime = require("../../utils/regenerator-runtime/runtime")

create(store, {
	data: {
		openid: "",
		userInfo: null,
    route:""
	},
	onLoad: function(options) {
    const _this = this
    _this.setData({
      route: '/' + options.route
    }) 
	},
	getUserInfo: function(e) {
		const self = this
		wx.getSetting({
			success: async res => {
				if (res.authSetting['scope.userInfo']) {
          wx.switchTab({ url:self.data.route })
				}else{
          wx.showModal({
            title: '错误',
            content: '未授权',
          })
        }
			}
		})
	},
  back: function(){
    const self = this
    wx.switchTab({ url: self.data.route })
  }
})
